<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/5/11
 * Time: 14:20
 */
namespace app\admin\model;

use think\Model;
use think\Db;

class MemberAttrModel extends Model {
    // 确定链接表名(客户属性)
    protected $name = 'member_attr';

    /**
     * [获取所有客户属性]
     */
    public function getAttrList(){

        return $this->select();
    }
    /**
     * [添加客户属性]
     */
    public function addAttr($where){
        if($this->insert($where)){
            return ['code'=>1,'msg'=>'添加成功'];
        }else{
            return ['code'=>0,'msg'=>'添加失败'];
        }
    }
    /**
     * [编辑客户属性]
     */
    public function editAttr($where){
        try{
            $this->where('id',$where['id'])->update($where);
            return ['code'=>1,'msg'=>'编辑成功'];
        }catch(\Exception $e){
            return ['code'=>0,'msg'=>'编辑失败'.$e->getMessage()];
        }
    }
    /**
     * [删除客户属性]
     */
    public function delAttr($where){
        if($this->where('id',$where)->delete()){
            return ['code'=>1,'msg'=>'删除成功'];
        }else{
            return ['code'=>0,'msg'=>'删除失败'];
        }
    }
}
